<%@ page import="com.nus.beans.User" %>
<%@ page import="java.util.List" %>
<%@ page import="com.nus.beans.UserType" %>
<%@ page import="org.apache.commons.lang3.StringEscapeUtils" %>
<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 9/24/12
  Time: 7:53 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<script type="text/javascript">
function submitForm(action) {
    form = document.getElementById('usersForm');

    form.action = action;
    form.submit();
}
</script>
    <%
    String errorMessage = (String) request.getAttribute("ERROR_MESSAGE");
        User currentUser = (User) session.getAttribute("user");
    %>
<title>User Information</title></head>
<body>
<P>User Information</P>
<form method="post" id="usersForm" >

<select name="users" size="10" >
<%
    List<User> userList = (List<User>) request.getAttribute("usersList");

    for(User user : userList){

%>

        <option value="<%=user.getUserId() %>"><%=user.getUserId()%><%="     "%> <%= StringEscapeUtils.escapeXml(user.getFirstName()) + "        " + StringEscapeUtils.escapeXml(user.getLastName()) + "&nbsp;&nbsp;&nbsp;&nbsp;" + user.getStatus().toString() + "&nbsp;&nbsp;&nbsp;&nbsp;" + user.getUserType()%> </option>
    <% } %>

</select>
    <%
    if(errorMessage != null){%>
    <%=errorMessage%>

    <% } %>
    <br/>
    <input type="button" value="View Info" onclick="submitForm('viewInfo.do')"/>
    <input type="button" value="Evaluations" onclick="submitForm('viewUserEvaluations.do')"/>
    <% if(currentUser.getUserType().equals(UserType.HR_ASST) || currentUser.getUserType().equals(UserType.HR_MGR)){ %>
    <input type="button" value="Activate" onclick="submitForm('activateUser.do')"/>
    <% } %>

    <% if(currentUser.getUserType().equals(UserType.HR_MGR)){%>
    <input type="button" value="Delete" onclick="submitForm('deleteUser.do')"/>
    <input type="button" value="Update" onclick="submitForm('LoadUpdateUser.do')"/>

    <% } %>
    <a href="viewHome.do">Home</a>
  </form>


</body>
</html>